# -*- conding:UTF-8 -*-

'''
@ Project: P7_lx1
@ File: create_flask.py
@ Author: 罗婷
@ Date：2022/6/8 19:11

'''
from flask import Flask
from flask_cors import CORS

from common.utils.token_auth import token_authcxx
from models import db
from views.Channel_view import channel_bp
from views.user_view import user_bp


def create_flask_app(info):
    app = Flask(__name__)
    app.config.from_object(info)
    # 蓝图 跨域 初始化项目db  钩子方法before_request
    app.register_blueprint(user_bp)
    app.register_blueprint(channel_bp)
    db.init_app(app)
    app.before_request(token_authcxx)
    CORS(app)

    return app



